package com.cloud.pole.msg.biz;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ace.cache.annotation.Cache;
import com.cloud.pole.common.biz.BaseBiz;
import com.cloud.pole.mapper.MsgNoticeMapper;
import com.cloud.pole.msg.model.entity.MsgNotice;
import com.cloud.pole.msg.model.entity.SmsTemplate;

import tk.mybatis.mapper.entity.Example;
@Service
@Transactional(rollbackFor = Exception.class)
public class MsgNoticeBiz extends BaseBiz<MsgNoticeMapper, MsgNotice>{
	
	@Autowired
	private MsgNoticeMapper mapper;

    @Cache(key="sysNoticeList{1}")
	public List<MsgNotice> getSysNoticeList(Integer userType) {
    	 Example example = new Example(MsgNotice.class);
         Example.Criteria criteria = example.createCriteria();
         criteria.andEqualTo("userType", userType);
         criteria.andEqualTo("contentType", MsgNotice.CONTENT_TYPE_SYSTEM);
         criteria.andEqualTo("noticeStatus", 1);
         criteria.andEqualTo("checkStatus", 1);
         example.setOrderByClause("notice_id desc");
         List<MsgNotice> list = mapper.selectByExample(example);
         return list;
	}
    
    @Cache(key="notice{1}")
    public MsgNotice selectByPrimaryKey(Integer noticeId) {
    	return super.selectById(noticeId);
    }
    
   	public List<MsgNotice> selectPageUserNoticeListByMap(Integer userType, Long userId) {
   		 Map<String, Object> map = new HashMap<String, Object>();
   		 map.put("userType", userType);
   		 map.put("userId", userId);
         return mapper.selectPageUserNoticeListByMap(map);
   	}
   	
   	
}
